
// 获取首页需要的数据
import { reqgetAllBrands, reqgetShoesTop, reqgetAllTypes, reqgetFemaleShoesTop, reqgetManShoesTop } from "@/api";
const state = {
    brandsList: [],
    goodsList: [],
    typeList: [],
    femaletop: [],
    mantop: []

};
const mutations = {
    GETALLBRANDS(state, brandsList) {
        state.brandsList = brandsList
    },
    GETSHOESTOP(state, goodsList) {
        state.goodsList = goodsList
    },
    GETALLTYPES(state, typeList) {
        state.typeList = typeList
    },
    FEMALETOP(state, femaletop) {
        state.femaletop = femaletop
    },
    MANTOP(state, mantop) {
        state.mantop = mantop
    }
};
const actions = {
    //获取品牌列表
    async getAllBrands({ commit }) {
        let result = await reqgetAllBrands();
        if (result.code == 200) {
            commit("GETALLBRANDS", result.data)
        }
        // console.log(result);
    },
    // 根据条件获取商品推荐列表 需要传参 sgender 和topWay
    async getShoesTop({ commit }, { sgender, topWay }) {
        let result = await reqgetShoesTop(sgender, topWay);
        if (result.code == 200) {
            commit("GETSHOESTOP", result.data)
        }
        // console.log(result)
    },
    // 获取分类信息
    async getAllTypes({ commit }) {
        let result = await reqgetAllTypes();
        // console.log(result)
        if (result.code == 200) {
            // commit('GETALLTYPES', result.data)
            commit("GETALLTYPES", result.data)
        }
    },
    // 获取女鞋榜单
    async getFemaleShoesTop({ commit }) {
        let result = await reqgetFemaleShoesTop()
        // console.log(result);
        if (result.code == 200) {
            commit("FEMALETOP", result.data)
        }
    },
    // 获取男鞋榜单 reqgetManShoesTop
    async getManShoesTop({ commit }) {
        let result = await reqgetManShoesTop()
        // console.log(result);
        if (result.code == 200) {
            commit("MANTOP", result.data)
        }
    }
};
const getters = {
};
export default {
    state, mutations, actions, getters
}
